<?php
$base_url = site_url();
$action = $base_url . 'matiere_premiere/createDB';
$ARTICLE_ID = null;
$ARTICLE_REF = null;
$ARTICLE_LIBELLE = null;
$ARTICLE_SEUIL = null;
$UNITE_ID = null;
if (isset($matiere_premiere)) {
    $action = site_url() . 'matiere_premiere/updateDB';
    $ARTICLE_ID = $matiere_premiere->ARTICLE_ID;
    $ARTICLE_REF = $matiere_premiere->ARTICLE_REF;
    $ARTICLE_LIBELLE = $matiere_premiere->ARTICLE_LIBELLE;
    $ARTICLE_SEUIL = $matiere_premiere->ARTICLE_SEUIL;
    $UNITE_ID = $matiere_premiere->UNITE_ID;
}
?>

<form action="<?php echo $action; ?>">
    <input type="hidden" id="ARTICLE_ID" value="<?php echo $ARTICLE_ID; ?>" />
    <fieldset>
        <legend>Nouvelle matière première</legend>
        <div>
            <label for="ARTICLE_REF">Référence de l'article</label>
            <input type="text" name="ARTICLE_REF" id="ARTICLE_REF" required="required" value="<?php echo $ARTICLE_REF; ?>" />
            <label for="ARTICLE_LIBELLE">Libellé de l'article</label>
            <input type="text" name="ARTICLE_LIBELLE" id="ARTICLE_LIBELLE" required="required" value="<?php echo $ARTICLE_LIBELLE; ?>" />
            <label for="ARTICLE_SEUIL">Seuil minimum de l'article</label>
            <input type="text" name="ARTICLE_SEUIL" id="ARTICLE_SEUIL" required="required" value="<?php echo $ARTICLE_SEUIL; ?>" />
            <label for="ARTICLE_SEUIL">Unité de l'article</label>
            <select name="UNITE_ID" id="UNITE_ID">
                <?php
                if (!isset($matiere_premiere)) {
                        ?>
                        <option value="" > --- </option>
                        <?php
                    }
                    
                foreach ($unites AS $unite) {
                    ?>
                    <option value="<?php echo $unite->UNITE_ID; ?> "

                            <?php
                            if ($UNITE_ID == $unite->UNITE_ID)
                                echo 'selected ';
                            ?>> 
                                <?php echo $unite->UNITE_LIBELLE;
                                ?>
                    </option>
                    <?php
                }
                ?>
            </select>


        </div>
    </fieldset>
</form>